<%@ page contentType="text/html; charset=utf-8" pageEncoding="utf-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="f" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="s" uri="http://stripes.sourceforge.net/stripes.tld" %>

<s:layout-render name="/newjsp.jsp">
    <s:layout-component name="hlavicka">
        <f:message key="nadpis.orders"/>
    </s:layout-component>

    <s:layout-component name="telo">
        <s:useActionBean beanclass="pneuservis.frontend.web.OrdersActionBean" var="actionBean"/>
        <f:message key="key.detailOrder"/>
        <div id="details">
        </div>
        <script>
            function showDetails(id) {
                console.log(id)
            }
        </script>
        <f:message key="key.allOrders" />
        <table class="zakladni">
            <tr>
                <th><f:message key="key.ID" /></th>
                <th><f:message key="key.tyreTypeId"/></th>
                <th><f:message key="key.tyresCount"/></th>
                <th><f:message key="key.customerId"/></th>
                <th><f:message key="key.vehicleBrand"/></th>
                <th><f:message key="key.status"/></th>
            </tr>
            <c:forEach items="${actionBean.orders}" var="order">
                <tr onclick="showDetails(${order.id})">
                    <td>${order.id}</td>
                    <td><c:out value="${order.tyreType.id}"/></td>
                    <td><c:out value="${order.tyresCount}"/></td>
                    <td><c:out value="${order.customer.id}"/></td>
                    <td><c:out value="${order.vehicleBrand}"/></td>
                    <td><c:out value="${order.status}"/></td>
                    <td><s:link beanclass="pneuservis.frontend.web.OrdersActionBean" event="delete" onclick="return confirm('Delete ${order}?');"><s:param name="orderid" value="${order.id}"/><f:message key="key.delete" /></s:link> </td>
                    <td><s:link beanclass="pneuservis.frontend.web.OrdersActionBean" event="edit"><s:param name="orderid" value="${order.id}"/><f:message key="key.edit" /></s:link> </td>
                    </tr>
            </c:forEach>
        </table>
        <div class="cleaner_h30"></div>
        <s:form beanclass="pneuservis.frontend.web.OrdersActionBean">
            <fieldset><legend><f:message key="key.newOrder"/></legend>
                <%@include file="formOrder.jsp"%>
                <s:submit name="add"><f:message key="key.newOrder1"/></s:submit>
                </fieldset>
        </s:form>
    </s:layout-component>
</s:layout-render>